package com.markerhub.controller;

import com.markerhub.common.lang.Result;
import com.markerhub.entity.Banner;
import com.markerhub.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Li Sipeng
 * @version 4.1 on   2022-12-07 13:54
 */
@RestController
public class BannerController {
    @Autowired
    private BannerService bannerservice;

    /**
     * 获取所有轮播图
     * */
    @PostMapping("/banner")
    public Result getBanner (){
        List<Banner> list = bannerservice.findAllBanner();
        return Result.succ(list);
    }

    /**
     * 根据id删除轮播图
     * */
    @PostMapping("/banner/del/{id}")
    public Result delBannerById (@PathVariable("id") Integer bannerid){
        Boolean b=  bannerservice.delBannerById(bannerid);
        return Result.succ(b);
    }

    /**
     * 新增轮播图
     * */
    @PostMapping("/banner/add")
    public Result delBannerById (@RequestBody Banner banner){
        Integer b = bannerservice.addBanner(banner);
        return Result.succ(b);
    }

    /**
     * 编辑轮播图
     * */
    @PostMapping("/banner/edit")
    public Result editBannerById (@RequestBody Banner banner){
        Integer b = bannerservice.editBanner(banner);
        return Result.succ(b);
    }

    /**
     * 上传轮播图图片文件
     * */
    @PostMapping("/banner/uploadfile")
    public Result uploadFile(){

        return Result.succ(null);
    }



}
